function Analysis_2_Figures(ResultName,Folder)

% load('Result_Baseline.mat');
% Folder          =   'TableGraphs\\IRF_Baseline\\';
load([ResultName,'.mat']);
mkdir(Folder);

% Setup
T_IRF           =   12;
List_Shock      =   {'Eps_Eta_M','Eps_Eta_Z'};

% IRF of Consumption Distribution
IRF_ConsDist    =   struct();
for ii_Irf=1:length(List_Shock)
    SH                  =   List_Shock{ii_Irf};
    IRF_ConsDist.(SH)   =   IRFAdd_ConsDist(PP,SS,MODEL,EquJac.HH_Aux,length(IRF.(SH).C),IRF.(SH));
end
%% Aggregate Variables
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
% Prices
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Rates to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    ID          =   1;
    Dev_Pir     =   IRF.(SH).Pir;
    Dev_ir      =   IRF.(SH).ir;
    Dev_rr      =   IRF.(SH).rr;
    TempIrf     =   [Dev_rr;Dev_ir;Dev_Pir]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Real Rate','Nominal Rate','Inflation'};
    List_LineStyle= {'-','--',':','-.';'k','b','r','m';2,2,2,2};
    
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);

    print('-depsc','-r1000',Fig,[Folder,'Prices_',SH]);
    close(Fig);
end

% Aggregate Quantities
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Demand to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    ID          =   1;
    
    Dev_C       =   IRF.(SH).C;
    Dev_Y       =   IRF.(SH).Y;
    
    LabelList   =   {'Aggregate Consumption','Aggregate Output'};
    List_LineStyle= {'-','--';'k','b';3,3};
    TempIrf     =   [Dev_C;Dev_Y];
    TempIrf     =   TempIrf(:,1:T_IRF+1)*100;
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
%     ax.YLim     =   [ax.YLim(1),max(TempIrf(:))];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggQuantity_',SH]);
    close(Fig);
end

% Aggregate Supply


%% Consumption Difference
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[0.75,1]*1/3; 
fig_gap     =   [0.05,0.08];
fig_VMargin =   [0.10,0.06];
fig_HMargin =   [0.20,0.04]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','northeast');
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
 
    %----------------------------------------------------------------------
    % By Different Characteristics
    %----------------------------------------------------------------------
    Dev_AggStat =   IRF.(SH).AggStat./SS.AggStat;
    Dev_AggStat(abs(Dev_AggStat)<1e-5)  =   0;
    Scale       =   [min(min(Dev_AggStat(1:2,:)));max(max(Dev_AggStat(1:2,:)))]*100;
    List_LineStyle= {'-','--';'k','b';2,2};
   
    % Rich vs. Poor
    Fig         =   FigureSetup(['By Asset, Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(2,:);Dev_AggStat(1,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'High Net Asset','Low Net Asset'};
    
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,Scale);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByAsset_',SH]);
    close(Fig);
end

%% Distribution of Consumption 
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[0.75,1]*1/3; 
fig_gap     =   [0.05,0.08];
fig_VMargin =   [0.10,0.06];
fig_HMargin =   [0.20,0.04]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','northeast');

ConsDistCell=   cell(1,length(List_Shock));
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   max(abs(IRF.(SH).C));
    ConsDist    =   IRF_ConsDist.(SH);
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Disp(1,:);ConsDist.Disp(3,:);ConsDist.Disp(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1)*100;
    LabelList   =   {'std','p75-p25','p90-p10'};
    List_LineStyle= {'-','--','-.';'r','c','m';2,2,2};
    
    Fig         =   FigureSetup(['Deviation Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Level_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Dispersion: Normalized
    %----------------------------------------------------------------------
    TempIrf     =   TempIrf/(MaxAbsC_Val*100);
    
    Fig         =   FigureSetup(['Deviation Dispersion: Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Normalized_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Gini and Top Shares
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Gini;ConsDist.TopShare(1,:);ConsDist.TopShare(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Gini','Top Share: 10\%','Top Share: 90\%'};
    List_LineStyle= {'-','--','-.';'r','c','m';2,2,2};
    
    Fig         =   FigureSetup(['Level Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
%     YLabel('Deviation from steady state (pp)');
    YLabel('Deviation from steady state');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_LevelDisp_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Variance Decomposition
    %----------------------------------------------------------------------
    TempIrfList =   {'NA'};
    TempIrf     =   zeros(length(TempIrfList),size(ConsDist.VarDec.NA,2));
    for jj=1:length(TempIrfList)
        TempIrf(jj,:)   =   ConsDist.VarDec.(TempIrfList{jj})(1,:);
    end
    TempIrf     =   TempIrf(:,MaxAbsC_Idx);
    TempTable   =   array2table(round(TempIrf,3),'VariableNames',{'WithinGroup'},...
                                                 'RowNames',TempIrfList);
    writetable(TempTable,[Folder,'IrfVarDec.xlsx'],'WriteRowNames',true,'Sheet',SH);
    %----------------------------------------------------------------------
    % Consumption IRF by Net Asset
    %----------------------------------------------------------------------
    Fig         =   FigureSetup(['Average Deviation by Net Asset, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Axis_X      =   ConsDist.SS.QQ_f';
    Axis_Y      =   ConsDist.AvgDev_byNA(:,MaxAbsC_Idx)'/MaxAbsC_Val;
    List_LineStyle= {'-';'b';2};
    [PH,ax]     =   MultiSeriesSoloPlot(Axis_X,Axis_Y,List_LineStyle);
%     ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
%     ax.XLim     =   [0,T_IRF];
    ax.XAxis.Exponent   =   0;
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Net Asset');
%     YLabel('Deviation from steady state (pp)');
    YLabel('Deviation from steady state');
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByNA_',SH]);
    close(Fig);
end
%% Appendix
VarDict     =   struct('C','Consumption','L','Hours','w','Wage','Y','Output',...
                       'ir','Nominal Rate','rr','Real Rate','Pir','Inflation' ...
                       );
                     
VarList     =   fieldnames(VarDict);

% Graph
Num_Var     =   length(VarList);
Num_Shock   =   length(List_Shock);

N_col       =   4;
N_row       =   ceil(Num_Var/N_col);
fig_size    =   [N_col,N_row].*[1,0.75]*1/4;  
fig_gap     =   [0.04,0.03];
fig_VMargin =   [0.03,0.03];
fig_HMargin =   [0.03,0.01]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    fig_Handle  =   FigureSetup(['IRF-',SH],fig_size);
    for ii_vv=1:Num_Var
        VV              =   VarList{ii_vv};
        ax              =   fig_SubPlot(ii_vv);
        if strcmp(VV,'CPI')
            TempIrf         =   cumsum(IRF.(SH).Pir);
        else
            TempIrf         =   IRF.(SH).(VV);
        end
        TempIrf(abs(TempIrf)<1e-6)  =   0;
        List_LineStyle  =   {'-';'k';2};
        [PH,ax]         =   IRFSoloPlot(TempIrf(:,1:T_IRF+1),List_LineStyle,1,ax);
        ax.XLim         =   [0,T_IRF];
        ax.FontSize     =   6;
        title(VarDict.(VV),'fontsize',8,'interpreter','latex');

    end

    print(fig_Handle,[Folder,'Full_',SH],'-depsc'); 
    close(fig_Handle);
end

%% Collect the Key Results
Num_Shock   =   length(List_Shock);
RowNames    =   {'Inflation','Aggregate Consumption', ...
                 'Consumption Dispersion','Consumption Gap'};
TableArray  =   zeros(length(RowNames),Num_Shock);

for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    [~,MaxIdx]  =   max(abs(IRF.(SH).C));
    TableArray(:,ii_sh) ...
                =   [IRF.(SH).Pir(MaxIdx)*100*4;...
                     IRF.(SH).C(MaxIdx)*100;...
                     [IRF_ConsDist.(SH).Disp(1,MaxIdx);...
                      (IRF.(SH).AggStat(1,MaxIdx)-IRF.(SH).AggStat(2,MaxIdx))]/...
                     abs(IRF.(SH).C(MaxIdx))];
end
KeyResults  =   array2table(TableArray,'RowNames',RowNames,'VariableNames',List_Shock);

writetable(KeyResults,[Folder,'KeyResults.xlsx'],'WriteRowNames',true);

%% Consumption Response by NA
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.05]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2f'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',1).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempLine    =   GR_Line('Style','-','Color',MyColor('Blue'),'Width',3);
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   TempFun_MaxC(IRF.(SH).C);
    ConsDist    =   IRF_ConsDist.(SH);
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   ConsDist.AvgDev_byNA(:,MaxAbsC_Idx)'/MaxAbsC_Val;
    
    Fig         =   FigureSetup(['Line Plot, Distributional Effect by NA, Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    XAxis       =   (1:1:size(ConsDist.AvgDev_byNA,1))';
    PH          =   TempLine.Plot(ax,XAxis,TempIrf);
    ax.YTick    =   Tick_Y(TempIrf);
    ax.XTick    =   XAxis;
    hline       = refline(0,1); 
    hline.Color = MyColor('Black');
    ax.XLim     =   [min(XAxis),max(XAxis)];
    ax.XTickLabel=  {'$\leq Q_{20}$', '$(Q_{20},Q_{40}]$', '$(Q_{40},Q_{60}]$', '$(Q_{60},Q_{80}]$', '$>Q_{80}$'};
    ax.TickLabelInterpreter = 'latex';
    XLabel('Net Wealth'); YLabel('Average Consumption Response');
    AxisSetup.Setup(ax);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByNA_',SH]);
    close(Fig);
end